package com.huaxia.day19;

import com.sun.xml.internal.ws.util.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class regularTest {

    public static void main(String[] args) {
        test1();
    }

    static void test1(){
        String aa = "aaabaabaaabaabcabd";
        System.out.println(aa.replaceAll("a{3}","AAA"));
        System.out.println(aa.replaceAll("a{1,3}","*"));
        System.out.println("12yuhu13hj4".replaceAll("\\d","*"));
        System.out.println("12yuhu13hj4".replaceAll("\\D","0"));

    }

    public static boolean isMobile(String str) {
        Pattern p = null;
        Matcher m = null;
        boolean b = false;
        String s2="^[1](([3|5|8][\\d])|([4][4,5,6,7,8,9])|([6][2,5,6,7])|([7][^9])|([9][1,8,9]))[\\d]{8}$";// 验证手机号
        if(str != null){
            p = Pattern.compile(s2);
            m = p.matcher(str);
            b = m.matches();
        }
        return b;
    }
}
